<?php
require_once("../../model/loai_mon_an_model.php");
$listall=m_lay_ds_loai();
	$start = (isset($_GET['start']) && (int)$_GET['start'])? $_GET['start']:0;
	$display = 4;
require("../_layout/m_header.php");
?>
<br />
<br />
<br />
<h2>Quản Lí Loại Món Ăn</h2>
<p>
<a href="them_loai_mon_an_view.php"><button class="btn btn-large btn-default"><span class="glyphicon glyphicon-plus"></span> Thêm Loại Món Ăn</button></a>
</p>
<table class="table table-hover">
  <tr>
  <th>Tên Thực Đơn</th>
  <th>Trạng Thái</th>
  <th>
  </tr>
  <?php
  $list=m_lay_ds_loai_index($start,$display);
while($row=mysqli_fetch_row($list))
{
    echo "<tr>";
    echo "<td>".$row[1]."</td>";
    if($row[2]==1)
    echo "<td>Hoạt Động</td>";
    else echo "<td>Khóa</td>";
    echo "<td><a href='sua_loai_mon_an_view.php?ma_loai=".$row[0]."'>Sửa</a> | <a href='../../controler/loai_mon_an_controller.php?ma_loai=".$row[0]."'>Xóa</a></td>";
    echo "</tr>";
}
?>
</table>
<br/>
<?php
							$next = $start + $display;
							$back = $start - $display;
							if ($back<0) {
								$back = 0;
							}
							if ($next>mysqli_num_rows($listall)) {
								$next = 0;
							}
							echo '<a href="m_loai_mon_an_view.php?start='.$back.'">Back</a> | ';
							echo '<a href="m_loai_mon_an_view.php?start='.$next.'">Next</a>';
							?>
<?php
require("../_layout/m_footer.php");
?>